#!/usr/bin/python
import json, argparse, os
from pprint import pprint

parser = argparse.ArgumentParser(description='Process an input JSON file that outputs an HTML output directory application. Provide an input file and an output directory.')
parser.add_argument('--if', dest='inputf', help='the json file you want to read from')
parser.add_argument('--od', dest='outputd', help='the output directory')

args = parser.parse_args()

#print args.inputf, args.outputd

# read the JSON file
try:
    # read the json file into a data container
    json_file = open(args.inputf)
    data = json.load(json_file) # load the json data as json

    # print the data
    # pprint(data)
    # data.close()

    # build the html file string
    html_output = '''
<!DOCTYPE html>
<html>
  <body>
'''

    html_file = str(args.outputd) + '/' + str(args.inputf)
    print(data['app-name'])
    print(data['version'])
    for segment in data['segments']:
        print segment
    print "output file stored in ", html_file
    
    
    #os.makedirs(args.outputd)
except:
    print "Can not read the input file."


